use tokio::time;

#[tokio::main]
async fn main() {

    let task1 = tokio::spawn(async {
        println!("task1 run");
        time::sleep(time::Duration::from_secs(5)).await;
        println!("task1 end");
    });

    let task2 = tokio::spawn(async {
        println!("task2 run");
        time::sleep(time::Duration::from_secs(6)).await;
        println!("task2 end");
    });

    println!("main run1");
    task1.await.unwrap();   // task1会阻塞当前线程，但是不会阻塞task2的执行
    println!("main run2");
    task2.await.unwrap();
    println!("main run3");
}